<template>
	<view class="container">
		<view class="carousel">
			<swiper indicator-dots circular="true" duration="400">
				<swiper-item class="swiper-item" v-for="(item, index) in gallery" :key="index">
					<view class="image-wrapper"><image :src="item" class="loaded" mode="aspectFill"></image></view>
				</swiper-item>
			</swiper>
		</view>

		<view class="introduce-section">
			<text class="title">{{ name }}</text>
			<view class="price-box">
				<text class="price-tip">{{ i18n.productProduct.money }}</text>
				<text class="price">{{ retailPrice }}</text>
				<!--<text class="m-price">¥488</text>
				<text class="coupon-tip">7折</text> -->
			</view>
			<!-- <view class="bot-row">
				<text>销量: 108</text>
				<text>库存: 4690</text>
				<text>浏览量: 768</text>
			</view> -->
		</view>

		<!--  分享 -->
		<view class="share-section" @click="share">
			<view class="share-icon">
				<text class="yticon icon-xingxing"></text>
				{{i18n.productProduct.return}}
			</view>
			<text class="tit">{{i18n.productProduct.shareredpack}}</text>
			<text class="yticon icon-bangzhu1"></text>
			<view class="share-btn">
				{{i18n.productProduct.sharenow}}
				<text class="yticon icon-you"></text>
			</view>
		</view>

		<view class="c-list">
			<view class="c-row b-b" @click="toggleSpec">
				<text class="tit">{{i18n.productProduct.specifications}}</text>
				<view class="con">
					<text class="selected-text">{{ tmpSpecText }}</text>
				</view>
				<text class="yticon icon-you"></text>
			</view>
			<!-- <view class="c-row b-b">
				<text class="tit">优惠券</text>
				<text class="con t-r red">领取优惠券</text>
				<text class="yticon icon-you"></text>
			</view> -->
			<!-- 	<view class="c-row b-b">
				<text class="tit">促销活动</text>
				<view class="con-list">
					<text>新人首单送20元无门槛代金券</text>
					<text>订单满50减10</text>
					<text>订单满100减30</text>
					<text>单笔购买满两件免邮费</text>
				</view>
			</view> -->
			<view class="c-row b-b">
				<text class="tit">{{i18n.productProduct.service}}</text>
				<view class="bz-list con">
					<text>{{i18n.productProduct.returninse}} ·</text>
					<text>{{i18n.productProduct.service2}} ·</text>
				</view>
			</view>
		</view>

		<!-- 评价 -->
		<view class="eva-section">
			<view class="e-header">
				<text class="tit">{{i18n.productProduct.comment}}</text>
				<text>({{ commentNum }})</text>
				<text class="tip">{{i18n.productProduct.goodcomment}}</text>
				<text class="yticon icon-you"></text>
			</view>
			<view class="eva-box" v-for="(item, index) in comment" :key="index">
				<image class="portrait" :src="item.avatar" mode="aspectFill"></image>
				<view class="right">
					<text class="name">{{ item.nickname }}</text>
					<text class="con">{{ item.content }}</text>
					<view class="bot">
						<!-- <text class="attr">购买类型：XL 红色</text> -->
						<text class="time">{{ item.addTime }}</text>
					</view>
				</view>
			</view>
		</view>
		<!-- 商品参数 -->
		<view class="goods-attr">
			<view class="t">{{i18n.productProduct.goodpar}}</view>
			<view class="l">
				<view class="item" v-for="(item, index) in attribute" :key="index">
					<text class="left">{{ item.attribute }}</text>
					<text class="right">{{ item.value }}</text>
				</view>
			</view>
		</view>

		<view class="detail-desc">
			<view class="d-header"><text>{{i18n.productProduct.gooddes}}</text></view>
			<rich-text :nodes="detail | formatRichText"></rich-text>
		</view>
		<!-- 常见问题 -->
		<view class="common-problem">
			<view class="h">
				<view class="line"></view>
				<text class="title">{{i18n.productProduct.question}}</text>
			</view>
			<view class="b">
				<view class="item" v-for="(item, index) in issue" :key="index">
					<view class="question-box">
						<text class="spot"></text>
						<text class="question">{{ item.question }}</text>
					</view>
					<view class="answer">{{ item.answer }}</view>
				</view>
			</view>
		</view>
		<!-- 大家都在看 -->
		<view class="related-goods">
			<view class="h">
				<view class="line"></view>
				<text class="title">{{i18n.productProduct.guesyou}}</text>
			</view>
			<view class="b">
				<view class="item" v-for="(item, index) in relatedList" :key="index" @click="navToDetailPage(item)">
					<image class="img" :src="item.picUrl" background-size="cover"></image>
					<text class="name">{{ item.name }}</text>
					<text class="price">￥{{ item.retailPrice }}</text>
				</view>
			</view>
		</view>
		<!-- 底部操作菜单 -->
		<view class="page-bottom">
			<navigator url="/pages/index/index" open-type="switchTab" class="p-b-btn">
				<text class="yticon icon-xiatubiao--copy"></text>
				<text>{{i18n.productProduct.indexpage}}</text>
			</navigator>
			<navigator @click="switchTabtocart" class="p-b-btn">
				<text class="yticon icon-gouwuche"></text>
				<text>{{i18n.productProduct.cart}}</text>
			</navigator>
			<view class="p-b-btn" :class="{ active: favorite }" @click="toFavorite">
				<text class="yticon icon-shoucang"></text>
				<text>{{i18n.productProduct.collection}}</text>
			</view>

			<view class="action-btn-group">
				<button type="primary" class=" action-btn no-border buy-now-btn" @click="buy">{{i18n.productProduct.buynow}}</button>
				<button type="primary" class=" action-btn no-border add-cart-btn" @click="addToCart">{{i18n.productProduct.tocart}}</button>
			</view>
		</view>

		<!-- 规格-模态层弹窗 -->
		<view class="popup spec" :class="specClass" @touchmove.stop.prevent="stopPrevent" @click="toggleSpec">
			<!-- 遮罩层 -->
			<view class="mask"></view>
			<view class="layer attr-content" @click.stop="stopPrevent">
				<view class="a-t">
					<image :src="checkGoodsAttrImg"></image>
					<view class="right">
						<text class="price">{{ i18n.productProduct.money }} {{ checkedSpecPrice }}</text>
						<text class="stock">{{i18n.productProduct.skunum}} : {{ checkedGoodsNumber }}{{i18n.productProduct.emu}}</text>
						<view class="selected">
							{{i18n.productProduct.selected}}：{{ tmpSpecText }}
							<!-- <text class="selected-text" v-for="(sItem, sIndex) in specSelected" :key="sIndex">
								{{sItem.name}}
							</text> -->
						</view>
					</view>
				</view>
				<view v-for="(item, index) in specificationList" :key="index" class="attr-list">
					<text>{{ item.name }}</text>
					<view class="item-list">
						<text
							v-for="(childItem, childIndex) in item.valueList"
							:key="childIndex"
							class="tit"
							:class="{ selected: childItem.selected }"
							@click="clickSkuValue(childItem)"
						>
							{{ childItem.value }}
						</text>
					</view>
				</view>
				<!-- <button class="btn" @click="toggleSpec">完成</button> -->
				<view class="number-item">
					<text>{{i18n.productProduct.num}}</text>
					<view class="selnum">
						<view class="cut" @tap="cutNumber">-</view>
						<input :value="number" class="number" disabled="true" type="number" />
						<view class="add" @tap="addNumber">+</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 分享 -->
		<share ref="share" :contentHeight="580"></share>
	</view>
</template>

<script>
import share from '@/components/share';
import { mapState } from 'vuex';
export default {
	components: {
		share
	},
	data() {
		return {
			specClass: 'none', //控制规格弹窗是否展示
			specSelected: [],
			favorite: false,
			specList: [],
			specChildList: [],
			goods: {},
			attribute: [], //商品参数
			brand: '', //品牌
			comment: [], //评论
			commentNum: '', //评论数量
			issue: [], //常见问题
			productList: [], //拼装好的规格
			specificationList: [], //拆分的规格
			shareImage: '', //分享图
			gallery: [], //轮播图
			retailPrice: '', //销售价格
			picUrl: '', //主图
			name: '', //商品标题
			detail: '', //商品详情
			relatedList: [], //智能推荐
			tmpSpecText: '', //选中的规格的值组成的字符串
			checkedSpecText: '',
			soldout: false,
			checkedSpecPrice: '', //选中规格的价格
			checkGoodsAttrImg: '', //选中规格的展示图
			checkedProductsId: '', //选中规格的id
			checkedGoodsNumber: 10, //选中规格的库存
			openAttr: false,
			number: 1,
			userHasCollect: 0
		};
	},
	computed: {
		...mapState(['hasLogin', 'userInfo']),

		i18n() {
			return this.$i18nMsg();
		}
	},
	async onLoad(options) {
		let title=this.$i18nMsg().pages.product;
		uni.setNavigationBarTitle({
			title
		});
		console.log(this.$i18nMsg().productProduct.money)
		console.log(this.$i18nMsg().productProduct.speificaselect)
		this.tmpSpecText= this.$i18nMsg().productProduct.speificaselect;
		let id = options.id;
		if (id) {
			//this.$api.msg(`点击了${id}`);
			let userInfo = uni.getStorageSync('userInfo') || '';
			uni.request({
				url: this.apiRoot + 'goods/detail?id=' + id,
				method: 'GET',
				header: {
					'Content-Type': 'application/json',
					'X-Litemall-Token': userInfo.token
				},
				data: {},
				success: res => {
					this.goods = res.data.data.info;
					this.attribute = res.data.data.attribute;
					this.brand = res.data.data.brand;
					this.comment = res.data.data.comment.data;
					this.commentNum = res.data.data.comment.count;
					this.issue = res.data.data.issue;
					this.productList = res.data.data.productList;
					this.specificationList = res.data.data.specificationList;
					this.shareImage = res.data.data.info.shareImage;
					this.gallery = res.data.data.info.gallery;
					this.retailPrice = res.data.data.info.retailPrice;
					this.picUrl = res.data.data.info.picUrl;
					this.name = res.data.data.info.name;
					this.detail = res.data.data.info.detail;
					this.checkedSpecPrice = res.data.data.info.retailPrice;
					this.checkGoodsAttrImg = res.data.data.info.picUrl;
					this.userHasCollect = res.data.data.userHasCollect;
					this.favorite = res.data.data.userHasCollect === 0 ? false : true;
				},
				fail: () => {},
				complete: () => {}
			});
			uni.request({
				url: this.apiRoot + 'goods/related?id=' + id,
				method: 'GET',
				data: {},
				success: res => {
					this.relatedList = res.data.data.list;
				},
				fail: () => {},
				complete: () => {}
			});
		}

		//规格 默认选中第一条
		// this.specList.forEach(item=>{
		// 	for(let cItem of this.specChildList){
		// 		if(cItem.pid === item.id){
		// 			this.$set(cItem, 'selected', true);
		// 			this.specSelected.push(cItem);
		// 			break; //forEach不能使用break
		// 		}
		// 	}
		// })
		// this.shareList = this.shareListConst;
	},
	methods: {
		//规格弹窗开关
		toggleSpec() {
			if (this.specClass === 'show') {
				this.specClass = 'hide';
				setTimeout(() => {
					this.specClass = 'none';
				}, 250);
			} else if (this.specClass === 'none') {
				this.specClass = 'show';
			}
		},
		//跳转并且刷新cart页面
		switchTabtocart(){
			uni.switchTab({
				url:'/pages/cart/cart',
				success: function(e) {
				//var page = getCurrentPages();
				//if (page == undefined || page == null) return;
				//page[page.length-1].$vm.loadData();
			}
			})
			//url="/pages/cart/cart" open-type="switchTab"
		},
		// 规格选择
		clickSkuValue: function(event) {
			let that = this;

			let specName = event.specification;
			let specValueId = event.id;

			//判断是否可以点击

			//TODO 性能优化，可在wx:for中添加index，可以直接获取点击的属性名和属性值，不用循环
			let _specificationList = this.specificationList;
			for (let i = 0; i < _specificationList.length; i++) {
				if (_specificationList[i].name === specName) {
					for (let j = 0; j < _specificationList[i].valueList.length; j++) {
						if (_specificationList[i].valueList[j].id == specValueId) {
							//如果已经选中，则反选
							// if (_specificationList[i].valueList[j].checked) {
							//   _specificationList[i].valueList[j].checked = false;
							// } else {
							//   _specificationList[i].valueList[j].checked = true;
							// }
							//以上代码带反选，实际操作中好像不需要反选
							_specificationList[i].valueList[j].checked = true;
						} else {
							_specificationList[i].valueList[j].checked = false;
						}
					}
				}
			}
			(this.specificationList = _specificationList),
				//重新计算spec改变后的信息
				this.changeSpecInfo();

			//重新计算哪些值不可以点击
		},
		// 规格改变时，重新计算价格及显示信息
		changeSpecInfo: function() {
			let checkedNameValue = this.getCheckedSpecValue();

			//设置选择的信息
			let checkedValue = checkedNameValue
				.filter(function(v) {
					if (v.valueId != 0) {
						return true;
					} else {
						return false;
					}
				})
				.map(function(v) {
					return v.valueText;
				});

			if (checkedValue.length > 0) {
				this.tmpSpecText = checkedValue.join('　');
			} else {
				this.tmpSpecText = '请选择规格数量';
			}

			if (this.isCheckedAllSpec()) {
				this.checkedSpecText = this.tmpSpecText;

				// 规格所对应的货品选择以后
				let checkedProductArray = this.getCheckedProductItem(this.getCheckedSpecKey());
				if (!checkedProductArray || checkedProductArray.length <= 0) {
					this.soldout = true;
					console.error('规格所对应货品不存在');
					return;
				}

				let checkedProduct = checkedProductArray[0];
				if (checkedProduct.number > 0) {
					this.checkedGoodsNumber = checkedProduct.number;
					this.checkedSpecPrice = checkedProduct.price;
					this.checkGoodsAttrImg = checkedProduct.url != null && checkedProduct.url != '' ? checkedProduct.url : this.checkGoodsAttrImg;
					this.soldout = false;
				} else {
					(this.checkedSpecPrice = this.goods.retailPrice),
						(this.checkGoodsAttrImg = checkedProduct.url != null && checkedProduct.url != '' ? checkedProduct.url : this.checkGoodsAttrImg);
					this.soldout = true;
				}
			} else {
				let _specificationList = this.specificationList;
				for (let i = 0; i < _specificationList.length; i++) {
					for (let j = 0; j < _specificationList[i].valueList.length; j++) {
						if (checkedValue[checkedValue.length - 1] == _specificationList[i].valueList[j].value) {
							if (_specificationList[i].valueList[j].picUrl != null && _specificationList[i].valueList[j].picUrl != '') {
								this.checkGoodsAttrImg = _specificationList[i].valueList[j].picUrl;
							}
							return;
						}
					}
				}
				this.checkedSpecText = '规格数量选择';
				(this.checkedSpecPrice = this.goods.retailPrice), (this.soldout = false);
			}
		},
		//判断规格是否选择完整
		isCheckedAllSpec: function() {
			return !this.getCheckedSpecValue().some(function(v) {
				if (v.valueId == 0) {
					return true;
				}
			});
		},

		getCheckedSpecKey: function() {
			let checkedValue = this.getCheckedSpecValue().map(function(v) {
				return v.valueText;
			});
			return checkedValue;
		},
		// 获取选中的产品（根据规格）
		getCheckedProductItem: function(key) {
			return this.productList.filter(function(v) {
				if (v.specifications.sort().toString() == key.sort().toString()) {
					return true;
				} else {
					return false;
				}
			});
		},
		//获取选中的规格信息
		getCheckedSpecValue: function() {
			let that = this;
			let checkedValues = [];
			let _specificationList = this.specificationList;
			for (let i = 0; i < _specificationList.length; i++) {
				let _checkedObj = {
					name: _specificationList[i].name,
					valueId: 0,
					valueText: ''
				};
				for (let j = 0; j < _specificationList[i].valueList.length; j++) {
					if (_specificationList[i].valueList[j].checked) {
						_checkedObj.valueId = _specificationList[i].valueList[j].id;
						_checkedObj.valueText = _specificationList[i].valueList[j].value;
					}
				}
				checkedValues.push(_checkedObj);
			}
			return checkedValues;
		},
		//分享
		share() {
			
			this.$refs.share.toggleMask();
		},
		//收藏
		toFavorite() {
			if (!this.hasLogin) {
				uni.navigateTo({
					url: '/pages/public/login'
				});
				return false;
			}
			this.favorite = !this.favorite;
			let userInfo = uni.getStorageSync('userInfo') || '';
			uni.request({
				url: this.apiRoot + 'collect/addordelete',
				method: 'POST',
				header: {
					'Content-Type': 'application/json',
					'X-Litemall-Token': userInfo.token
				},
				data: {
					type: 0,
					valueId: this.goods.id
				},
				success: res => {
					///用绝对值实现 0 和1的改变
					this.userHasCollect = Math.abs(this.userHasCollect - 1);
				},
				fail: () => {},
				complete: () => {}
			});
		},
		///立即购买
		buy() {
			//规格窗口未打开状态，直接打开规格窗口，若规格窗口处于打开状态，则直接进行购物车添加判断
			if (this.specClass != 'show') {
				this.specClass = 'show';
			} else {
				//提示选择完整规格
				if (!this.isCheckedAllSpec()) {
					uni.showToast({
						title: '请选择完整规格'
					});
					return false;
				}
				if (!this.hasLogin) {
					uni.navigateTo({
						url: '/pages/public/login'
					});
					return false;
				}
				this.specClass = 'none';

				//根据选中的规格，判断是否有对应的sku信息
				let checkedProductArray = this.getCheckedProductItem(this.getCheckedSpecKey());
				if (!checkedProductArray || checkedProductArray.length <= 0) {
					//找不到对应的product信息，提示没有库存
					uni.showToast({
						title: '没有库存'
					});
					return false;
				}
				let checkedProduct = checkedProductArray[0];
				//验证库存
				if (checkedProduct.number <= 0) {
					uni.showToast({
						title: '没有库存'
					});
					return false;
				}
				let userInfo = uni.getStorageSync('userInfo') || '';
				//立即购买
				uni.request({
					url: this.apiRoot + 'cart/fastadd',
					method: 'POST',
					header: {
						'Content-Type': 'application/json',
						'X-Litemall-Token': userInfo.token
					},
					data: { goodsId: checkedProduct.goodsId, number: this.number, productId: checkedProduct.id },
					success: res => {
						uni.navigateTo({
							url: `/pages/order/createOrder?cartid=` + res.data.data
						});
						//this.navTo(`/pages/order/createOrder?cartid=`+res.data.data);
					},
					fail: () => {},
					complete: () => {}
				});
			}
		},
		//添加到购物车
		addToCart: function() {
			//规格窗口未打开状态，直接打开规格窗口，若规格窗口处于打开状态，则直接进行购物车添加判断
			if (this.specClass != 'show') {
				this.specClass = 'show';
			} else {
				//提示选择完整规格
				if (!this.isCheckedAllSpec()) {
					uni.showToast({
						title: '请选择完整规格'
					});
					return false;
				}
				if (!this.hasLogin) {
					uni.navigateTo({
						url: '/pages/public/login'
					});
					return false;
				}
				this.specClass = 'none';
				//根据选中的规格，判断是否有对应的sku信息
				let checkedProductArray = this.getCheckedProductItem(this.getCheckedSpecKey());
				if (!checkedProductArray || checkedProductArray.length <= 0) {
					//找不到对应的product信息，提示没有库存
					uni.showToast({
						title: '没有库存'
					});
					return false;
				}
				let checkedProduct = checkedProductArray[0];
				//验证库存
				if (checkedProduct.number <= 0) {
					uni.showToast({
						title: '没有库存'
					});
					return false;
				}
				//添加到购物车
				let userInfo = uni.getStorageSync('userInfo') || '';
				uni.request({
					url: this.apiRoot + 'cart/add',
					method: 'POST',
					header: {
						'Content-Type': 'application/json',
						'X-Litemall-Token': userInfo.token
					},
					data: { goodsId: checkedProduct.goodsId, number: this.number, productId: checkedProduct.id },
					success: res => {
						let _res = res.data;
						if (_res.errno == 0) {
							uni.showToast({
								title: '添加成功'
							});
							this.openAttr = !this.openAttr;
							this.cartGoodsCount = _res.data;
						} else {
							uni.showToast({
								title: _res.errMsg
							});
						}
					},
					fail: () => {},
					complete: () => {}
				});
			}
		},

		//},
		cutNumber: function() {
			this.number = this.number - 1 > 1 ? this.number - 1 : 1;
		},
		addNumber: function() {
			this.number = this.number + 1;
		},
		stopPrevent() {}
	},
	filters: {
		/**
		 * 处理富文本里的图片宽度自适应
		 * 1.去掉img标签里的style、width、height属性
		 * 2.img标签添加style属性：max-width:100%;height:auto
		 * 3.修改所有style里的width属性为max-width:100%
		 * 4.去掉<br/>标签
		 * @param html
		 * @returns {void|string|*}
		 */
		formatRichText(html) {
			//控制小程序中图片大小
			let newContent = html.replace(/<img[^>]*>/gi, function(match, capture) {
				match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '');
				match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
				match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
				return match;
			});
			newContent = newContent.replace(/style="[^"]+"/gi, function(match, capture) {
				match = match.replace(/width:[^;]+;/gi, 'max-width:100%;').replace(/width:[^;]+;/gi, 'max-width:100%;');
				return match;
			});
			newContent = newContent.replace(/<br[^>]*\/>/gi, '');
			newContent = newContent.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:inline-block;margin:10upx auto;"');
			return newContent;
		}
	}
};
</script>

<style lang="scss">
page {
	background: $page-color-base;
	padding-bottom: 160upx;
}
.icon-you {
	font-size: $font-base + 2upx;
	color: #888;
}
.carousel {
	height: 722upx;
	position: relative;
	swiper {
		height: 100%;
	}
	.image-wrapper {
		width: 100%;
		height: 100%;
	}
	.swiper-item {
		display: flex;
		justify-content: center;
		align-content: center;
		height: 750upx;
		overflow: hidden;
		image {
			width: 100%;
			height: 100%;
		}
	}
}

/* 标题简介 */
.introduce-section {
	background: #fff;
	padding: 20upx 30upx;

	.title {
		font-size: 32upx;
		color: $font-color-dark;
		height: 50upx;
		line-height: 50upx;
	}
	.price-box {
		display: flex;
		align-items: baseline;
		height: 64upx;
		padding: 10upx 0;
		font-size: 26upx;
		color: $uni-color-primary;
	}
	.price {
		font-size: $font-lg + 2upx;
	}
	.m-price {
		margin: 0 12upx;
		color: $font-color-light;
		text-decoration: line-through;
	}
	.coupon-tip {
		align-items: center;
		padding: 4upx 10upx;
		background: $uni-color-primary;
		font-size: $font-sm;
		color: #fff;
		border-radius: 6upx;
		line-height: 1;
		transform: translateY(-4upx);
	}
	.bot-row {
		display: flex;
		align-items: center;
		height: 50upx;
		font-size: $font-sm;
		color: $font-color-light;
		text {
			flex: 1;
		}
	}
}
/**商品参数*/
.goods-attr {
	width: 750upx;
	height: auto;
	overflow: hidden;
	padding: 0 31.25upx 25upx 31.25upx;
	margin-top: 16upx;
	background: #fff;

	.t {
		width: 687.5upx;
		height: 104upx;
		line-height: 104upx;
		font-size: 38.5upx;
	}

	.item {
		width: 687.5upx;
		height: 68upx;
		padding: 11upx 20upx;
		margin-bottom: 11upx;
		background: #f7f7f7;
		font-size: 38.5upx;
	}

	.left {
		float: left;
		font-size: 25upx;
		width: 134upx;
		height: 45upx;
		line-height: 45upx;
		overflow: hidden;
		color: #999;
	}

	.right {
		float: left;
		font-size: 36.5upx;
		margin-left: 20upx;
		width: 480upx;
		height: 45upx;
		line-height: 45upx;
		overflow: hidden;
		color: #333;
	}
}

/* 分享 */
.share-section {
	display: flex;
	align-items: center;
	color: $font-color-base;
	background: linear-gradient(left, #fdf5f6, #fbebf6);
	padding: 12upx 30upx;
	.share-icon {
		display: flex;
		align-items: center;
		width: 70upx;
		height: 30upx;
		line-height: 1;
		border: 1px solid $uni-color-primary;
		border-radius: 4upx;
		position: relative;
		overflow: hidden;
		font-size: 22upx;
		color: $uni-color-primary;
		&:after {
			content: '';
			width: 50upx;
			height: 50upx;
			border-radius: 50%;
			left: -20upx;
			top: -12upx;
			position: absolute;
			background: $uni-color-primary;
		}
	}
	.icon-xingxing {
		position: relative;
		z-index: 1;
		font-size: 24upx;
		margin-left: 2upx;
		margin-right: 10upx;
		color: #fff;
		line-height: 1;
	}
	.tit {
		font-size: $font-base;
		margin-left: 10upx;
	}
	.icon-bangzhu1 {
		padding: 10upx;
		font-size: 30upx;
		line-height: 1;
	}
	.share-btn {
		flex: 1;
		text-align: right;
		font-size: $font-sm;
		color: $uni-color-primary;
	}
	.icon-you {
		font-size: $font-sm;
		margin-left: 4upx;
		color: $uni-color-primary;
	}
}

.c-list {
	font-size: $font-sm + 2upx;
	color: $font-color-base;
	background: #fff;
	.c-row {
		display: flex;
		align-items: center;
		padding: 20upx 30upx;
		position: relative;
	}
	.tit {
		width: 140upx;
	}
	.con {
		flex: 1;
		color: $font-color-dark;
		.selected-text {
			margin-right: 10upx;
		}
	}
	.bz-list {
		height: 40upx;
		font-size: $font-sm + 2upx;
		color: $font-color-dark;
		text {
			display: inline-block;
			margin-right: 30upx;
		}
	}
	.con-list {
		flex: 1;
		display: flex;
		flex-direction: column;
		color: $font-color-dark;
		line-height: 40upx;
	}
	.red {
		color: $uni-color-primary;
	}
}

/* 评价 */
.eva-section {
	display: flex;
	flex-direction: column;
	padding: 20upx 30upx;
	background: #fff;
	margin-top: 16upx;
	.e-header {
		display: flex;
		align-items: center;
		height: 70upx;
		font-size: $font-sm + 2upx;
		color: $font-color-light;
		.tit {
			font-size: $font-base + 2upx;
			color: $font-color-dark;
			margin-right: 4upx;
		}
		.tip {
			flex: 1;
			text-align: right;
		}
		.icon-you {
			margin-left: 10upx;
		}
	}
}
.eva-box {
	display: flex;
	padding: 20upx 0;
	.portrait {
		flex-shrink: 0;
		width: 80upx;
		height: 80upx;
		border-radius: 100px;
	}
	.right {
		flex: 1;
		display: flex;
		flex-direction: column;
		font-size: $font-base;
		color: $font-color-base;
		padding-left: 26upx;
		.con {
			font-size: $font-base;
			color: $font-color-dark;
			padding: 20upx 0;
		}
		.bot {
			display: flex;
			justify-content: space-between;
			font-size: $font-sm;
			color: $font-color-light;
		}
	}
}
/*  详情 */
.detail-desc {
	background: #fff;
	margin-top: 16upx;
	.d-header {
		display: flex;
		justify-content: center;
		align-items: center;
		height: 80upx;
		font-size: $font-base + 2upx;
		color: $font-color-dark;
		position: relative;

		text {
			padding: 0 20upx;
			background: #fff;
			position: relative;
			z-index: 1;
		}
		&:after {
			position: absolute;
			left: 50%;
			top: 50%;
			transform: translateX(-50%);
			width: 300upx;
			height: 0;
			content: '';
			border-bottom: 1px solid #ccc;
		}
	}
}

/* 规格选择弹窗 */
.attr-content {
	padding: 10upx 30upx;
	.a-t {
		display: flex;
		image {
			width: 170upx;
			height: 170upx;
			flex-shrink: 0;
			margin-top: -40upx;
			border-radius: 8upx;
		}
		.right {
			display: flex;
			flex-direction: column;
			padding-left: 24upx;
			font-size: $font-sm + 2upx;
			color: $font-color-base;
			line-height: 42upx;
			.price {
				font-size: $font-lg;
				color: $uni-color-primary;
				margin-bottom: 10upx;
			}
			.selected-text {
				margin-right: 10upx;
			}
		}
	}
	.attr-list {
		display: flex;
		flex-direction: column;
		font-size: $font-base + 2upx;
		color: $font-color-base;
		padding-top: 30upx;
		padding-left: 10upx;
	}
	.item-list {
		padding: 20upx 0 0;
		display: flex;
		flex-wrap: wrap;
		text {
			display: flex;
			align-items: center;
			justify-content: center;
			background: #eee;
			margin-right: 20upx;
			margin-bottom: 20upx;
			border-radius: 100upx;
			min-width: 60upx;
			height: 60upx;
			padding: 0 20upx;
			font-size: $font-base;
			color: $font-color-dark;
		}
		.selected {
			background: #fbebee;
			color: $uni-color-primary;
		}
	}
}

/*  弹出层 */
.popup {
	position: fixed;
	left: 0;
	top: 0;
	right: 0;
	bottom: 0;
	z-index: 91;

	&.show {
		display: block;
		.mask {
			animation: showPopup 0.2s linear both;
		}
		.layer {
			animation: showLayer 0.2s linear both;
		}
	}
	&.hide {
		.mask {
			animation: hidePopup 0.2s linear both;
		}
		.layer {
			animation: hideLayer 0.2s linear both;
		}
	}
	&.none {
		display: none;
	}
	.mask {
		position: fixed;
		top: 0;
		width: 100%;
		height: 100%;
		z-index: 1;
		background-color: rgba(0, 0, 0, 0.4);
	}
	.layer {
		position: fixed;
		z-index: 91;
		bottom: 0;
		width: 100%;
		min-height: 40vh;
		border-radius: 10upx 10upx 10upx 10upx;
		margin-bottom: 133upx;
		background-color: #fff;
		.btn {
			height: 66upx;
			line-height: 66upx;
			border-radius: 100upx;
			background: $uni-color-primary;
			font-size: $font-base + 2upx;
			color: #fff;
			margin: 30upx auto 20upx;
		}
	}

	.number-item {
		color: #606266;

		.selnum {
			width: 322rpx;
			height: 71rpx;
			border: 1px solid #ccc;
			margin-left: 20upx;
			margin-top: 20upx;
			display: flex;
		}

		.cut {
			width: 93.75rpx;
			height: 100%;
			text-align: center;
			line-height: 65rpx;
		}

		.number {
			flex: 1;
			height: 100%;
			text-align: center;
			line-height: 68.75rpx;
			border-left: 1px solid #ccc;
			border-right: 1px solid #ccc;
			float: left;
			padding: 10upx;
		}

		.add {
			width: 93.75rpx;
			height: 100%;
			text-align: center;
			line-height: 65rpx;
		}
	}
	@keyframes showPopup {
		0% {
			opacity: 0;
		}
		100% {
			opacity: 1;
		}
	}
	@keyframes hidePopup {
		0% {
			opacity: 1;
		}
		100% {
			opacity: 0;
		}
	}
	@keyframes showLayer {
		0% {
			transform: translateY(120%);
		}
		100% {
			transform: translateY(0%);
		}
	}
	@keyframes hideLayer {
		0% {
			transform: translateY(0);
		}
		100% {
			transform: translateY(120%);
		}
	}
}
/**常见问题**/
.common-problem {
	width: 750upx;
	height: auto;
	overflow: hidden;

	.h {
		position: relative;
		height: 145.5upx;
		width: 750upx;
		padding: 56.25upx 0;
		background: #fff;
		text-align: center;

		.line {
			display: inline-block;
			position: absolute;
			top: 72upx;
			left: 0;
			z-index: 2;
			height: 1px;
			margin-left: 225upx;
			width: 300upx;
			background: #ccc;
		}

		.title {
			display: inline-block;
			position: absolute;
			top: 56.125upx;
			left: 0;
			z-index: 3;
			height: 33upx;
			margin-left: 285upx;
			width: 180upx;
			background: #fff;
		}
	}
	.b {
		width: 750upx;
		height: auto;
		overflow: hidden;
		padding: 0upx 30upx;
		background: #fff;
	}

	.item {
		display: flex;
		flex-direction: column;
		height: auto;
		overflow: hidden;
		padding-bottom: 25upx;
	}

	.question-box {
		.spot {
			float: left;
			display: block;
			height: 8upx;
			width: 8upx;
			background: #f08790;
			border-radius: 50%;
			margin-top: 11upx;
		}

		.question {
			float: left;
			line-height: 30upx;
			padding-left: 8upx;
			display: block;
			font-size: 26upx;
			padding-bottom: 15upx;
			color: #303030;
		}
	}
	.answer {
		line-height: 36upx;
		padding-left: 16upx;
		font-size: 26upx;
		color: #787878;
	}
}
/* 大家都在看 */

.related-goods {
	width: 750upx;
	height: auto;
	overflow: hidden;
	padding-bottom: 80upx;

	.h {
		position: relative;
		height: 145.5upx;
		width: 750upx;
		padding: 56.25rpx 0;
		background: #fff;
		text-align: center;
		border-bottom: 1px solid #f4f4f4;

		.line {
			display: inline-block;
			position: absolute;
			top: 72upx;
			left: 0;
			z-index: 2;
			height: 1px;
			margin-left: 225upx;
			width: 300upx;
			background: #ccc;
		}

		.title {
			display: inline-block;
			position: absolute;
			top: 56.125upx;
			left: 0;
			z-index: 3;
			font-size: 29upx;
			height: 33upx;
			margin-left: 285upx;
			width: 180upx;
			background: #fff;
		}
	}
	.b {
		width: 750upx;
		height: auto;
		overflow: hidden;

		.item {
			float: left;
			background: #fff;
			width: 375upx;
			height: auto;
			overflow: hidden;
			text-align: center;
			padding: 15rpx 31.25upx;
			border-right: 1px solid #f4f4f4;
			border-bottom: 1px solid #f4f4f4;
		}
	}
	.item {
		.img {
			width: 311.45upx;
			height: 311.45upx;
		}

		.name {
			display: block;
			width: 311.45upx;
			height: 35upx;
			margin: 11.5rpx 0 15rpx 0;
			text-align: center;
			overflow: hidden;
			font-size: 30upx;
			color: #333;
		}

		.price {
			display: block;
			width: 311.45upx;
			height: 30upx;
			text-align: center;
			font-size: 30upx;
			color: #f08790;
		}
	}
}
/* 底部操作菜单 */
.page-bottom {
	position: fixed;
	left: 30upx;
	bottom: 30upx;
	z-index: 95;
	display: flex;
	justify-content: center;
	align-items: center;
	width: 690upx;
	height: 100upx;
	background: rgba(255, 255, 255, 0.9);
	box-shadow: 0 0 20upx 0 rgba(0, 0, 0, 0.5);
	border-radius: 16upx;

	.p-b-btn {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		font-size: $font-sm;
		color: $font-color-base;
		width: 96upx;
		height: 80upx;
		.yticon {
			font-size: 40upx;
			line-height: 48upx;
			color: $font-color-light;
		}
		&.active,
		&.active .yticon {
			color: $uni-color-primary;
		}
		.icon-fenxiang2 {
			font-size: 42upx;
			transform: translateY(-2upx);
		}
		.icon-shoucang {
			font-size: 46upx;
		}
	}
	.action-btn-group {
		display: flex;
		height: 76upx;
		border-radius: 100px;
		overflow: hidden;
		box-shadow: 0 20upx 40upx -16upx #fa436a;
		box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
		background: linear-gradient(to right, #ffac30, #fa436a, #f56c6c);
		margin-left: 20upx;
		position: relative;
		&:after {
			content: '';
			position: absolute;
			top: 50%;
			right: 50%;
			transform: translateY(-50%);
			height: 28upx;
			width: 0;
			border-right: 1px solid rgba(255, 255, 255, 0.5);
		}
		.action-btn {
			display: flex;
			align-items: center;
			justify-content: center;
			width: 180upx;
			height: 100%;
			font-size: $font-base;
			padding: 0;
			border-radius: 0;
			background: transparent;
		}
	}
}
</style>
